package com.itheima.cloudconsumerorder80.controller;


import com.itheima.pojo.CommentResult;
import com.itheima.pojo.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

@RestController
@Slf4j

public class OrderController {
    @Autowired
    private RestTemplate restTemplate;

    private static final String PARAMENT_URL = "http://CLOUD-PROVIDER-SERVICE";

    @GetMapping("/consumer/payment/findById/{id}")
    public CommentResult findById(@PathVariable("id") Integer id) {
        return this.restTemplate.getForObject(PARAMENT_URL + "/payment/findById/" + id, CommentResult.class);
    }

    @PostMapping("/consumer/payment/insert")
    public CommentResult insert(@RequestBody Payment payment) {
        return this.restTemplate.postForObject(PARAMENT_URL + "/payment/insert", payment, CommentResult.class);
    }
}
